package trading_strategy.orders;

import trading_strategy.instruments.ListedInstrument;

/**
 * Created by IntelliJ IDEA.
 * User: gderoujoux
 * Date: 6 mai 2010
 * Time: 11:14:01
 * To change this template use File | Settings | File Templates.
 */
public class LimitWithStopLossOrder extends LimitOrder {
    double stopLoss;
    public LimitWithStopLossOrder(ListedInstrument instrument, int qty, double price, double stopLoss, String comment, IOrderAutomaton automaton, long ts) {
        super(instrument, qty, price, comment, automaton, ts);
        this.stopLoss = stopLoss;
        if (qty < 0 && stopLoss >= price && qty > 0 && stopLoss <= price) {
            throw new IllegalArgumentException("Invalid stop loss value");
        }
    }

    public double getStopLoss() {
        return stopLoss;
    }

    public String toString() {
        return "LIMIT " + getQty() + "@" + getLimit() + " SL: " + getStopLoss();
    }
}